var moment = require('moment');
var _ = require('underscore');

module.exports = function (app) {
  app.get('/mobile/user/:userId/app/:appId/ajax/ajaxdata.json', function (req, res) {
    if (!req.query.domainId) {
      res.status(200).json({
        "result": [{
          "combData": {
            "count": 9,
            "et": 1452873600000,
            "max": 3000,
            "min": 300,
            "st": 1452700800000,
            "total": 11400
          },
          "data": [{
            "count": 9,
            "et": 1452873600000,
            "max": 3000,
            "min": 300,
            "st": 1452700800000,
            "total": 11400
          }],
          "key": {
            "id": 599,
            "name": "/news/"
          }
        }, {
          "combData": {
            "count": 3,
            "et": 1452873600000,
            "max": 1200,
            "min": 1200,
            "st": 1452700800000,
            "total": 2400
          },
          "data": [{
            "count": 3,
            "et": 1452873600000,
            "max": 1200,
            "min": 1200,
            "st": 1452700800000,
            "total": 2400
          }],
          "key": {
            "id": 582,
            "name": "/"
          }
        }],
        "timeSpan": {
          "endTime": 1453100400000,
          "startTime": 1451800800000
        }
      });
    }
  });

  app.get('/mobile/user/:userId/app/:appId/ajax/ajaxerrordata.json', function (req, res) {
    if (!req.query.domainId) {
      res.status(200).json({
        "result": [{
          "combData": {
            "count": 12,
            "et": 1453096800000,
            "st": 1451797200000,
            "val": 5
          },
          "data": [{
            "count": 0,
            "et": 1451836800000,
            "st": 1451797200000,
            "val": 0
          }, {
            "count": 0,
            "et": 1451923200000,
            "st": 1451836800000,
            "val": 0
          }, {
            "count": 0,
            "et": 1452009600000,
            "st": 1451923200000,
            "val": 0
          }, {
            "count": 0,
            "et": 1453096800000,
            "st": 1453046400000,
            "val": 0
          }],
          "id": 581,
          "name": "www.baidu.com"
        }],
        "timeSpan": {
          "endTime": 1453096800000,
          "startTime": 1451797200000
        }
      });
    }
  });

  app.get('/mobile/user/:userId/app/:appId/ajax/ajaxtracelist.json', function (req, res) {
    res.status(200).json({
      "ajaxTraceListResults": [{
        "affected": 1,
        "avg": 800,
        "count": 3,
        "domain": "www.baidu.com",
        "domainId": 581,
        "firstTime": 1452759467000,
        "id": 0,
        "keyStr": "581_582",
        "lastTime": 1452828748000,
        "url": "/",
        "urlId": 582,
        "val": 2400
      }, {
        "affected": 1,
        "avg": 800,
        "count": 3,
        "domain": "www.baidu.com",
        "domainId": 581,
        "firstTime": 1452759565000,
        "id": 0,
        "keyStr": "581_599",
        "lastTime": 1452759956000,
        "url": "/news/",
        "urlId": 599,
        "val": 2400
      }],
      "endTime": 1453096800000,
      "startTime": 1451797200000
    });
  })
};
